#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include "String.h"
using namespace std;


void test_string1()
{
	bit::string s1("hello world");
	cout << s1.c_str() << endl;

	bit::string s2;
	cout << s2.c_str() << endl;

	for (size_t i = 0; i < s1.size(); i++)
	{
		cout << s1[i] << " ";
	}
	cout << endl;

	bit::string::iterator it = s1.begin();
	while (it != s1.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;

	for (auto ch : s1)
	{
		cout << ch << " ";

	}
	cout << endl;
}

void test_string2()
{
	bit::string s1("hello world");
	cout << s1.c_str() << endl;
	s1.push_back(' ');
	s1.push_back('#');
	s1.append("hello bit");
	cout << s1.c_str() << endl;

	bit::string s2("hello world");
	cout << s2.c_str() << endl;
	s2 += ' ';
	s2 += '#';
	s2 += "hello bit";
	cout << s2.c_str() << endl;
}

void test_string3()
{
	bit::string s1("hello world");
	cout << s1.c_str() << endl;
	s1.insert(5,3,'#');
	cout << s1.c_str() << endl;

	bit::string s2("hello world");
	cout << s2.c_str() << endl;
	s2.insert(5,"nihao");
	cout << s2.c_str() << endl;
}

void test_string4()
{
	bit::string s1("hello world");
	cout << s1.c_str() << endl;

	s1.erase(5, 3);
	cout << s1.c_str() << endl;
}

void test_string5()
{
	bit::string s("hello world");
	s.resize(8);
	cout << s << endl;
	s.resize(13, 'x');
	cout << s << endl;
	s.resize(20, 'y');
	cout << s << endl;
}

void test_string6()
{
	bit::string ss("hello world");
	ss += '\0';
	ss += "////////////";
	cout << ss.c_str() << endl;
	cout << ss << endl;
	
	bit::string copy(ss);
	cout << ss << endl;
	cout << copy << endl;
	
}

void test_string7()
{
	//char buff[128];
	//for (size_t i = 0; i < 5; i++)
	//{
	//	cin >> buff[i];
	//}
	//for (size_t i = 0; i < 5; i++)
	//{
	//	cout << buff[i];
	//}
	bit::string s;
	cin >> s;
	cout << s << endl;

	cin >> s;
	cout << s << endl;
}

void test_string8()
{
	bit::string s1("hello");
	bit::string s2("hello");
	cout << (s1 < s2) << endl;
	cout << (s1 > s2) << endl;
	cout << (s1 == s2) << endl<<endl;

	bit::string s3("hello");
	bit::string s4("helloxxx");
	cout << (s3 < s4) << endl;
	cout << (s3 > s4) << endl;
	cout << (s3 == s4) << endl<<endl;

	bit::string s5("helloxxx");
	bit::string s6("hello");
	cout << (s5 < s6) << endl;
	cout << (s5 > s6) << endl;
	cout << (s5 == s6) << endl<<endl;
}

void test_string9()
{
	bit::string s1("hello");
	bit::string s2(s1);
	
	cout << s1 << endl;
	cout << s2 << endl;
	bit::string s3("xxxxxxxxxxxxxxxxxxxxxx");
	s1 = s3;
	cout << s1 << endl;
	cout << s3<< endl;
}

int main()
{
	test_string9();
	return 0; 
}
